package com.zhang.hadoop.testMain;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

/**
 * @author zhang yufei
 * @date 2023/1/6 18:56
 **/
public class Test9 {

    public static void main(String args[]) throws Exception {
        String file = "/Users/zhangyufei/0-program/work/data/redis-op-popup-data-0-appendonly.aof";
        FileInputStream inputStream = new FileInputStream(file);
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));

        String str = null;
        Map<String, String> map = new HashMap<>();
        String key = null;
        while ((str = bufferedReader.readLine()) != null) {
            if (str.contains("clientType:3_userId:")) {
                Integer begin = str.indexOf("clientType:3_userId:");
                Integer end = str.indexOf("_env:3");
                try {
                    key = str.substring(begin, end);
                }catch (Exception e){
                    System.out.println(str);
                }
            }
            if (str.contains("campaignId\":693180,\"end")) {
                map.put(key, "693180");
            }
        }
        for (Map.Entry<String, String> entry : map.entrySet()) {
            System.out.println(entry.getKey() + "\t" + entry.getValue());
        }
        //close
        inputStream.close();
        bufferedReader.close();
    }
}
